home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / pyxmpp / objects.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  2KB  |  90 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. __revision__ = '$Id: objects.py 647 2006-08-26 18:27:39Z jajcus $'
  5. __docformat__ = 'restructuredtext en'
  6. import libxml2
  7. from pyxmpp.xmlextra import common_doc
  8.  
  9. class StanzaPayloadObject(object):
  10.     xml_element_name = None
  11.     xml_element_namespace = None
  12.     
  13.     def as_xml(self, parent = None, doc = None):
  14.         if parent:
  15.             if not doc:
  16.                 n = parent
  17.                 while n:
  18.                     if n.type == 'xml_document':
  19.                         doc = n
  20.                         break
  21.                     
  22.                     n = n.parent
  23.                 if not doc:
  24.                     doc = common_doc
  25.                 
  26.             
  27.             
  28.             try:
  29.                 ns = parent.searchNsByHref(doc, self.xml_element_namespace)
  30.             except libxml2.treeError:
  31.                 ns = None
  32.  
  33.             xmlnode = parent.newChild(ns, self.xml_element_name, None)
  34.             if not ns:
  35.                 ns = xmlnode.newNs(self.xml_element_namespace, None)
  36.                 xmlnode.setNs(ns)
  37.             
  38.             doc1 = doc
  39.         elif doc:
  40.             doc1 = doc
  41.         else:
  42.             doc1 = libxml2.newDoc('1.0')
  43.         xmlnode = doc1.newChild(None, self.xml_element_name, None)
  44.         ns = xmlnode.newNs(self.xml_element_namespace, None)
  45.         xmlnode.setNs(ns)
  46.         self.complete_xml_element(xmlnode, doc1)
  47.         if doc or parent:
  48.             return xmlnode
  49.         
  50.         doc1.setRootElement(xmlnode)
  51.         return doc1
  52.  
  53.     
  54.     def complete_xml_element(self, xmlnode, doc):
  55.         pass
  56.  
  57.  
  58.  
  59. class StanzaPayloadWrapperObject(object):
  60.     
  61.     def as_xml(self, parent = None, doc = None):
  62.         if parent:
  63.             if not doc:
  64.                 n = parent
  65.                 while n:
  66.                     if n.type == 'xml_document':
  67.                         doc = n
  68.                         break
  69.                     
  70.                     n = n.parent
  71.                 if not doc:
  72.                     doc = common_doc
  73.                 
  74.             
  75.             copy = self.xmlnode.docCopyNode(doc, True)
  76.             parent.addChild(copy)
  77.             return copy
  78.         elif not doc:
  79.             doc1 = libxml2.newDoc('1.0')
  80.         else:
  81.             doc1 = doc
  82.         xmlnode = doc1.addChild(self.xmlnode.docCopyNode(doc, True))
  83.         doc1.setRootElement(xmlnode)
  84.         if doc:
  85.             return xmlnode
  86.         
  87.         return doc1
  88.  
  89.  
  90.